home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / a-strmap.ads < prev    next >
Text File  |  1994-05-19  |  5KB  |  104 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                     A D A . S T R I N G S . M A P S                       --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.7 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  22. --                                                                          --
  23. ------------------------------------------------------------------------------
  24.  
  25.  
  26. package Ada.Strings.Maps is
  27.    pragma Pure;
  28.  
  29.    --------------------------------
  30.    -- Character Set Declarations --
  31.    --------------------------------
  32.  
  33.    type Character_Set is array (Character range <>) of Boolean;
  34.    pragma Pack (Character_Set);
  35.    --  Representation for a set of character values:
  36.  
  37.    Null_Set : constant Character_Set ('b' .. 'a') := (others => False);
  38.    --  Note that the null set can have any range, with the element values
  39.    --  being False, but we choose to make it a null range since this is
  40.    --  more efficient. The particular choice of null range is arbitrary.
  41.  
  42.    subtype Character_Sequence is String;
  43.    --  Alternative representation for a set of character values:
  44.  
  45.    ----------------------------------
  46.    -- Operations on Character Sets --
  47.    ----------------------------------
  48.  
  49.    function "="   (Left, Right : Character_Set) return Boolean;
  50.  
  51.    function "not" (Right : Character_Set)       return Character_Set;
  52.    function "and" (Left, Right : Character_Set) return Character_Set;
  53.    function "or"  (Left, Right : Character_Set) return Character_Set;
  54.    function "xor" (Left, Right : Character_Set) return Character_Set;
  55.  
  56.    function Is_In
  57.      (Element : Character; Set : Character_Set) return Boolean;
  58.  
  59.    function Is_Subset
  60.      (Elements : Character_Set; Set : Character_Set) return Boolean;
  61.  
  62.    function "<="
  63.      (Left  : Character_Set; Right : Character_Set) return Boolean
  64.      renames Is_Subset;
  65.  
  66.    function To_Set (Sequence : Character_Sequence) return Character_Set;
  67.  
  68.    function To_Set (Singleton : Character) return Character_Set;
  69.  
  70.    function To_Sequence (Set : Character_Set) return Character_Sequence;
  71.  
  72.    ------------------------------------
  73.    -- Character Mapping Declarations --
  74.    ------------------------------------
  75.  
  76.    type Character_Mapping is array (Character range <>) of Character;
  77.    pragma Pack (Character_Mapping);
  78.    --  Representation for a character to character mapping:
  79.  
  80.    ----------------------------
  81.    -- Operations on Mappings --
  82.    ----------------------------
  83.  
  84.    function To_Mapping
  85.      (From, To : Character_Sequence) return Character_Mapping;
  86.  
  87.    ----------------------
  88.    -- Identity Mapping --
  89.    ----------------------
  90.  
  91.    Identity : constant Character_Mapping ('1' .. '0') := (others => ' ');
  92.    --  ??? Identity should be a deffered constant. But it blows up the
  93.    --  compiler right now
  94.  
  95. private
  96.    pragma Inline (Is_In);
  97.  
  98.    --   Identity : constant Character_Mapping ('1' .. '0') := (others => ' ');
  99.    --  Note that any null range would do. We want to use a null range,
  100.    --  rather than a filled in identity mapping so that the test for
  101.    --  an identity mapping in routines like Count is rapid.
  102.  
  103. end Ada.Strings.Maps;
  104.